package com.kld.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.kld.common.core.domain.entity.SysDept;
import com.kld.common.utils.StringUtils;
import com.kld.common.core.page.TableDataInfo;
import com.kld.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.kld.system.domain.SysSyncTime;
import com.kld.system.mapper.SysSyncTimeMapper;
import com.kld.system.service.ISysSyncTimeService;

import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author kld
 * @date 2022-06-17
 */
@RequiredArgsConstructor
@Service
public class SysSyncTimeServiceImpl implements ISysSyncTimeService {

    private final SysSyncTimeMapper baseMapper;



    /**
     * 新增【请填写功能名称】
     *
     * @param bo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public Boolean insertByBo(SysSyncTime bo) {
        SysSyncTime add = BeanUtil.toBean(bo, SysSyncTime.class);
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setId(add.getId());
        }
        return flag;
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param bo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public Boolean updateByBo(SysSyncTime bo) {
        SysSyncTime update = BeanUtil.toBean(bo, SysSyncTime.class);
        return baseMapper.updateById(update) > 0;
    }

    /**
     * 修改或新增一个syncTime
     *
     * @param syncTime 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertOrUpdateSyncTime(SysSyncTime syncTime) {
        SysSyncTime newTime = baseMapper.selectById(syncTime.getId());
        int result = 0;
        if(newTime==null){
            result =  baseMapper.insert(syncTime);
        }else{
            result =  baseMapper.updateById(syncTime);
        }
        return result;
    }

    @Override
    public SysSyncTime selectSyncTimeById(Long id) {
        return baseMapper.selectById(id);
    }
}
